home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / CHRFOUND.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  1KB  |  49 lines

  1. /*********
  2. * Function: CHRFOUND
  3. * By:    Tom Rettig
  4. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  5. *
  6. *  Syntax: CHRFOUND( <string1>, <string2> )
  7. *  Return: True if every character in <string1> is also contained in <string2>,
  8. *             regardless of order, otherwise False
  9. *          <string1> and <string2> are both <expC>
  10. *********/
  11.  
  12. #include "trlib.h"
  13.  
  14. TRTYPE chrfound()
  15. {
  16.    char *s1, *s2, *s3;
  17.    int found = FALSE;
  18.  
  19.    if ( PCOUNT==2 && ISCHAR(1) && ISCHAR(2) )
  20.    {
  21.       s1 = _parc(1);
  22.       s2 = _parc(2);
  23.       s3 = _parc(2);
  24.  
  25.       while ( *s1 )
  26.       {
  27.          while ( *s2 )
  28.          {
  29.             if ( *s1 == *s2++ )
  30.             {
  31.                found = TRUE;
  32.                break;
  33.             }
  34.          }
  35.          if ( found && *(++s1) )       /* more chars remain to check */
  36.          {
  37.             found = FALSE;
  38.             s2 = s3;
  39.          }
  40.          else
  41.             break;
  42.       }
  43.       _retl( found );
  44.    }
  45.    else
  46.       _retl( ERROR );    /* error on logical */
  47. }
  48.  
  49.